//
// Created by Tony on 2024/7/24.
//

#include "AccessFlag.h"
#include "../../common/KeyWords.h"
#include <sstream>

namespace RtCode {

std::string AccessFlag::toString() const {
    std::stringstream ss;
    ss << "flags:";

    if (isFlag(PUBLIC)) {
        ss << " " << KeyWords::PUBLIC;
    }
    if (isFlag(PRIVATE)) {
        ss << " " << KeyWords::PRIVATE;
    }
    if (isFlag(PROTECTED)) {
        ss << " " << KeyWords::PROTECT;
    }
    if (isFlag(STATIC)) {
        ss << " " << KeyWords::STATIC;
    }
    if (isFlag(FINAL)) {
        ss << " ";
    }
    if (isFlag(SYNCHRONIZED)) {
        ss << " ";
    }
    if (isFlag(VOLATILE)) {
        ss << " ";
    }
    if (isFlag(TRANSIENT)) {
        ss << " ";
    }
    if (isFlag(VARARGS)) {
        ss << " ";
    }
    if (isFlag(NATIVE)) {
        ss << " " << KeyWords::NATIVE;
    }
    if (isFlag(INTERFACE)) {
        ss << " ";
    }
    if (isFlag(ABSTRACT)) {
        ss << " ";
    }
    if (isFlag(STRICT)) {
        ss << " ";
    }
    if (isFlag(SYNTHETIC)) {
        ss << " ";
    }
    if (isFlag(ANNOTATION)) {
        ss << " ";
    }
    if (isFlag(ENUM)) {
        ss << " ";
    }

    return ss.str();
}

} // namespace RtCode
